#include "webpage.h"

#include <QDialog>
#include <QMessageBox>

WebPage::WebPage(QWebEngineProfile *profile, QWidget *parent)
    : QWebEnginePage(profile, parent)
{

}


/**
 * @brief WebPage::certificateError, 证书出错处理
 * @param certificateError
 * @return
 */
bool WebPage::certificateError(const QWebEngineCertificateError &certificateError)
{
    QMessageBox msgBox;
    QString errorDetail = certificateError.errorDescription();
    msgBox.setText("target certificate unnormal: " + errorDetail);
    msgBox.setInformativeText(tr("continue access?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Ok);
    int ret = msgBox.exec();
    if(ret == QMessageBox::Ok){

        return true;
    }else if(ret == QMessageBox::Cancel){
        emit certificateErrorSignal();
        return false;
    }

    return  false;
}
